package service.impl;

import BBS.bean.PageInfo;
import mapper.PageMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import service.PageService;

import javax.servlet.ServletContext;
import java.util.List;

public class PageServiceImpl implements PageService {
    private PageMapper pm;
    private SqlSession session;

    public PageServiceImpl(ServletContext application) {
        SqlSessionFactory ssf = (SqlSessionFactory) application.getAttribute("SqlSessionFactory");
        session = ssf.openSession();
        pm = session.getMapper(PageMapper.class);
    }


    @Override
    public List<PageInfo> findPageAll() {
        List<PageInfo> list = pm.findPageAll();
        session.close();
        return list;
    }
}
